﻿using Ext.Net.MVC;
using System;
using System.Collections.Generic;
using Ext.Net;
using Sharp.Portal;
using Sharp.Portal.ExtNet;
using Sharp.Portal.Other;
using Column = Ext.Net.MVC.ColumnAttribute;
using DateColumn = Ext.Net.MVC.DateColumnAttribute;


namespace Sharp.WebBooter.Areas.Platform.Models
{
    [Title("角色管理")]
    [DataHandler(ModuleOP.Details, "浏览", 0)]
    [DataHandler(ModuleOP.Create, "新增", 1)]
    [DataHandler(ModuleOP.Edit, "修改", 2)]
    [DataHandler(ModuleOP.Delete, "删除", 3)]
    [DataHandler(ModuleOP.Refresh, "刷新", 4)]
    [DataHandler("Permission", "权限", 5)]
    public partial class RoleIndexViewModel : ExtSharpList
    {
        public RoleIndexViewModel()
        {
            this.Feature = ListFeature.MultiSelect | ListFeature.Paging | ListFeature.RowNumber;
            this.IsUseOrgTreeLayout = true;
            this.ToolbarButtonParameters.Add(new ToolButtonInfo()
            {
                Mode = "Permission",
                Direct = new ToolButtonInfo.DirectClickAction("ListForRole", "Permission"),
                Parameters = new List<ToolButtonInfo.Parameter>()
                {
                    new ToolButtonInfo.Parameter("owner", "role", (int) ParameterMode.Auto),
                    new ToolButtonInfo.Parameter("roleId",
                        "this.up('grid').getSelectionModel().getSelection()[0].getData().Id", (int) ParameterMode.Raw),
                    new ToolButtonInfo.Parameter("ownerId",
                        "this.up('grid').getSelectionModel().getSelection()[0].getData().Id", (int) ParameterMode.Raw)
                }
            });
        }

        [Column( Text = "Id")]
        public Guid Id { get; set; }

        /// <summary>
        /// 名称
        /// </summary>
        [Column(Width = 100, Text = "名称")]
        public string Name { get; set; }

        /// <summary>
        ///     备注
        /// </summary>
        [Column(Width = 300, Text = "备注")]
        public string Remark { get; set; }

        [DateColumn(Width = 144, Text = "录入时间", Format = "yyyy-MM-dd HH:mm:ss")]
        public DateTime? CreatedTime { get; set; }


        /// <summary>
        /// 修改时间
        /// </summary>
        [DateColumn(Width = 144, Text = "修改时间", Format = "yyyy-MM-dd HH:mm:ss")]
        public DateTime? ModifiTime { get; set; }

        [Column(Text = "修改人")]
        public string ModifiedUserName { get; set; }
        

        public SelectedRowCollection InitiallySelectedRows { get; set; }
    }
}